﻿using System;
using System.Collections.Generic;
using System.Text;

using YouHP.Model;
using YouHP.DALFactory;
using YouHP.Utility;
using YouHP.Model.Group;

namespace YouHP.BLL
{
    public class GroupTypeBLL
    {
        #region Singleton
        static GroupTypeBLL _Instance;
        public static GroupTypeBLL Instance
        {
            get
            {
                if (_Instance == null)
                {
                    _Instance = new GroupTypeBLL();
                }
                return _Instance;
            }
        }
        #endregion

        #region basic operations
        public bool AddGroupType(GroupTypeInfo info)
        {
            return DataAccess.GroupTypeDAL.AddGroupType(info);
        }

        public bool UpdateGroupType(GroupTypeInfo info)
        {
            return DataAccess.GroupTypeDAL.UpdateGroupType(info);
        }

        public bool DeleteGroupType(int[] ids)
        {
            return DataAccess.GroupTypeDAL.DeleteGroupType(ids);
        }

        public GroupTypeInfo GetGroupTypeInfo(int id)
        {
            return DataAccess.GroupTypeDAL.GetGroupTypeInfo(id);
        }
        #endregion

        #region list and search operations
        public List<GroupTypeInfo> GetGroupTypeList(int pageSize, int pageIndex, out int count)
        {
            return DataAccess.GroupTypeDAL.GetGroupTypeList(pageSize, pageIndex, out count);
        }

        /*search for management*/
        public List<GroupTypeInfo> GetAllGroupTypeByName(string keyword)
        {
            int count = 0;
            return DataAccess.GroupTypeDAL.GetGroupTypeByName(Constants.maxPageSize, 1, keyword, out count);
        }

        public List<GroupTypeInfo> GetAllGroupType()
        {
            return GetAllGroupTypeByName("");
        }
        #endregion
    }
}